import { _ as _export_sfc, m as mpMixin, a as mixin, j as resolveEasycom, J as __easycom_0, k as resolveDynamicComponent, c as createBlock, o as openBlock, w as withCtx, b as createVNode, i as index$g, n as normalizeStyle, e as createCommentVNode, r as renderSlot, ae as Input, s as index$i, M as withModifiers, f as normalizeClass, t as createTextVNode, u as toDisplayString, aF as hideKeyboard, x as useMainStore, y as storeToRefs, z as ref, al as useNavbarHeight, B as onLoad, g as createElementBlock, H as unref, F as Fragment, G as __easycom_0$1, h as renderList, p as index$q, Y as kmUnit, X as formatDateTime, aG as $emit, ag as navigateBack, ak as getCurrentPages$1, av as openLocation, a2 as makePhoneCall } from './index-Cc4oxzDN.js';
import { _ as __easycom_4 } from './uv-button.CpuKY_t2.js';
import { s as shopGetListWithShopKeeper, a as shopGetList } from './market.DCE5Fo51.js';
import './uv-loading-icon.DuNkB54M.js';

const props = {
	props: {
		value: {
			type: [String, Number],
			default: ''
		},
		modelValue: {
			type: [String, Number],
			default: ''
		},
		// 搜索框形状，round-圆形，square-方形
		shape: {
			type: String,
			default: 'round'
		},
		// 搜索框背景色，默认值#f2f2f2
		bgColor: {
			type: String,
			default: '#f2f2f2'
		},
		// 占位提示文字
		placeholder: {
			type: String,
			default: '请输入关键字'
		},
		// 是否启用清除控件
		clearabled: {
			type: Boolean,
			default: true
		},
		// 是否自动聚焦
		focus: {
			type: Boolean,
			default: false
		},
		// 是否在搜索框右侧显示取消按钮
		showAction: {
			type: Boolean,
			default: true
		},
		// 右边控件的样式
		actionStyle: {
			type: Object,
			default: () => ({})
		},
		// 取消按钮文字
		actionText: {
			type: String,
			default: '搜索'
		},
		// 输入框内容对齐方式，可选值为 left|center|right
		inputAlign: {
			type: String,
			default: 'left'
		},
		// input输入框的样式，可以定义文字颜色，大小等，对象形式
		inputStyle: {
			type: Object,
			default: () => ({})
		},
		// 是否禁用输入框
		disabled: {
			type: Boolean,
			default: false
		},
		// 边框颜色
		borderColor: {
			type: String,
			default: 'transparent'
		},
		// 搜索图标的颜色，默认同输入框字体颜色
		searchIconColor: {
			type: String,
			default: '#909399'
		},
		// 输入框字体颜色
		color: {
			type: String,
			default: '#606266'
		},
		// placeholder的颜色
		placeholderColor: {
			type: String,
			default: '#909399'
		},
		// 左边输入框的图标，可以为uvui图标名称或图片路径
		searchIcon: {
			type: String,
			default: 'search'
		},
		searchIconSize: {
			type: [Number, String],
			default: 22
		},
		// 组件与其他上下左右元素之间的距离，带单位的字符串形式，如"30px"、"30px 20px"等写法
		margin: {
			type: String,
			default: '0'
		},
		// 开启showAction时，是否在input获取焦点时才显示
		animation: {
			type: Boolean,
			default: false
		},
		// 输入框最大能输入的长度，-1为不限制长度(来自uniapp文档)
		maxlength: {
			type: [String, Number],
			default: -1
		},
		// 搜索框高度，单位px
		height: {
			type: [String, Number],
			default: 32
		},
		// 搜索框左侧文本
		label: {
			type: [String, Number, null],
			default: null
		},
		// 搜索框扩展样式
		boxStyle: {
			type: [String, Object],
			default: () => ({})
		},
		...uni.$uv?.props?.search
	}
};

/**
	 * search 搜索框
	 * @description 搜索组件，集成了常见搜索框所需功能，用户可以一键引入，开箱即用。
	 * @tutorial https://www.uvui.cn/components/search.html
	 * @property {String}			value/v-model				输入框初始值
	 * @property {String}			shape				搜索框形状，round-圆形，square-方形（默认 'round' ）
	 * @property {String}			bgColor				搜索框背景颜色（默认 '#f2f2f2' ）
	 * @property {String}			placeholder			占位文字内容（默认 '请输入关键字' ）
	 * @property {Boolean}			clearabled			是否启用清除控件（默认 true ）
	 * @property {Boolean}			focus				是否自动获得焦点（默认 false ）
	 * @property {Boolean}			showAction			是否显示右侧控件（默认 true ）
	 * @property {Object}			actionStyle			右侧控件的样式，对象形式
	 * @property {String}			actionText			右侧控件文字（默认 '搜索' ）
	 * @property {String}			inputAlign			输入框内容水平对齐方式 （默认 'left' ）
	 * @property {Object}			inputStyle			自定义输入框样式，对象形式
	 * @property {Boolean}			disabled			是否启用输入框（默认 false ）
	 * @property {String}			borderColor			边框颜色，配置了颜色，才会有边框 (默认 'transparent' )
	 * @property {String}			searchIconColor		搜索图标的颜色，默认同输入框字体颜色 (默认 '#909399' )
	 * @property {Number | String}	searchIconSize 搜索图标的字体，默认22
	 * @property {String}			color				输入框字体颜色（默认 '#606266' ）
	 * @property {String}			placeholderColor	placeholder的颜色（默认 '#909399' ）
	 * @property {String}			searchIcon			输入框左边的图标，可以为uvui图标名称或图片路径  (默认 'search' )
	 * @property {String}			margin				组件与其他上下左右元素之间的距离，带单位的字符串形式，如"30px"   (默认 '0' )
	 * @property {Boolean} 			animation			是否开启动画，见上方说明（默认 false ）
	 * @property {String | Number}	maxlength			输入框最大能输入的长度，-1为不限制长度  (默认 '-1' )
	 * @property {String | Number}	height				输入框高度，单位px（默认 64 ）
	 * @property {String | Number}	label				搜索框左边显示内容
	 * @property {Object} boxStyle 自定义内容框样式，设置padding 
	 * @property {Object}			customStyle			定义需要用到的外部样式
	 *
	 * @event {Function} change 输入框内容发生变化时触发
	 * @event {Function} search 用户确定搜索时触发，用户按回车键，或者手机键盘右下角的"搜索"键时触发
	 * @event {Function} custom 用户点击右侧控件时触发
	 * @event {Function} clear 用户点击清除按钮时触发
	 * @example <uv-search placeholder="日照香炉生紫烟" v-model="keyword"></uv-search>
	 */
	const _sfc_main$1 = {
		name: "uv-search",
		emits: ['click', 'input', 'change', 'clear', 'search', 'custom', 'focus', 'blur', 'clickIcon', 'update:modelValue'],
		mixins: [mpMixin, mixin, props],
		data() {
			return {
				keyword: '',
				showClear: false, // 是否显示右边的清除图标
				show: false,
				// 标记input当前状态是否处于聚焦中，如果是，才会显示右侧的清除控件
				focused: this.focus
			};
		},
		created() {




			this.keyword = this.modelValue;

		},
		watch: {
			value(nVal){
				this.keyword = nVal;
			},
			modelValue(nVal){
				this.keyword = nVal;
			}
		},
		computed: {
			showActionBtn() {
				return !this.animation && this.showAction
			}
		},
		methods: {
			keywordChange(){
				this.$emit('input', this.keyword);
				this.$emit('update:modelValue', this.keyword);
				this.$emit('change', this.keyword);
			},
			// 目前HX2.6.9 v-model双向绑定无效，故监听input事件获取输入框内容的变化
			inputChange(e) {
				this.keyword = e.detail.value;
				this.keywordChange();
			},
			// 清空输入
			// 也可以作为用户通过this.$refs形式调用清空输入框内容
			clear() {
				this.keyword = '';
				this.$nextTick(() => {
					this.$emit('clear');
				});
				this.keywordChange();
			},
			// 确定搜索
			search(e) {
				this.$emit('search', e.detail.value);
				try {
					// 收起键盘
					hideKeyboard();
				} catch (e) {}
			},
			// 点击右边自定义按钮的事件
			custom() {
				this.$emit('custom', this.keyword);
				try {
					// 收起键盘
					hideKeyboard();
				} catch (e) {}
			},
			// 获取焦点
			getFocus() {
				this.focused = true;
				// 开启右侧搜索按钮展开的动画效果
				if (this.animation && this.showAction) this.show = true;
				this.$emit('focus', this.keyword);
			},
			// 失去焦点
			blur() {
				// 最开始使用的是监听图标@touchstart事件，自从hx2.8.4后，此方法在微信小程序出错
				// 这里改为监听点击事件，手点击清除图标时，同时也发生了@blur事件，导致图标消失而无法点击，这里做一个延时
				setTimeout(() => {
					this.focused = false;
				}, 100);
				this.show = false;
				this.$emit('blur', this.keyword);
			},
			// 点击搜索框，只有disabled=true时才发出事件，因为禁止了输入，意味着是想跳转真正的搜索页
			clickHandler() {
				if (this.disabled) this.$emit('click');
			},
			// 点击左边图标
			clickIcon() {
				this.$emit('clickIcon');
			}
		}
	};

function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_v_uni_view = index$g;
  const _component_uv_icon = resolveEasycom(resolveDynamicComponent("uv-icon"), __easycom_0);
  const _component_v_uni_input = Input;
  const _component_v_uni_text = index$i;

  return (openBlock(), createBlock(_component_v_uni_view, {
    class: "uv-search",
    onClick: $options.clickHandler,
    style: normalizeStyle([{
			margin: _ctx.margin,
		}, _ctx.$uv.addStyle(_ctx.customStyle)])
  }, {
    default: withCtx(() => [
      createVNode(_component_v_uni_view, {
        class: "uv-search__content",
        style: normalizeStyle([{
				backgroundColor: _ctx.bgColor,
				borderRadius: _ctx.shape == 'round' ? '100px' : '4px',
				borderColor: _ctx.borderColor,
			},_ctx.$uv.addStyle(_ctx.boxStyle)])
      }, {
        default: withCtx(() => [
          (_ctx.disabled)
            ? (openBlock(), createBlock(_component_v_uni_view, {
                key: 0,
                class: "uv-search__content__disabled"
              }))
            : createCommentVNode("", true),
          renderSlot(_ctx.$slots, "prefix", {}, () => [
            createVNode(_component_v_uni_view, { class: "uv-search__content__icon" }, {
              default: withCtx(() => [
                createVNode(_component_uv_icon, {
                  onClick: $options.clickIcon,
                  size: _ctx.searchIconSize,
                  name: _ctx.searchIcon,
                  color: _ctx.searchIconColor ? _ctx.searchIconColor : _ctx.color
                }, null, 8, ["onClick", "size", "name", "color"])
              ]),
              _: 1
            })
          ], true),
          createVNode(_component_v_uni_input, {
            "confirm-type": "search",
            onBlur: $options.blur,
            value: $data.keyword,
            onConfirm: $options.search,
            onInput: $options.inputChange,
            disabled: _ctx.disabled,
            onFocus: $options.getFocus,
            focus: _ctx.focus,
            maxlength: _ctx.maxlength,
            "placeholder-class": "uv-search__content__input--placeholder",
            placeholder: _ctx.placeholder,
            "placeholder-style": `color: ${_ctx.placeholderColor}`,
            class: "uv-search__content__input",
            type: "text",
            style: normalizeStyle([{
					textAlign: _ctx.inputAlign,
					color: _ctx.color,
					backgroundColor: _ctx.bgColor,
					height: _ctx.$uv.addUnit(_ctx.height)
				}, _ctx.inputStyle])
          }, null, 8, ["onBlur", "value", "onConfirm", "onInput", "disabled", "onFocus", "focus", "maxlength", "placeholder", "placeholder-style", "style"]),
          ($data.keyword && _ctx.clearabled && $data.focused)
            ? (openBlock(), createBlock(_component_v_uni_view, {
                key: 1,
                class: "uv-search__content__icon uv-search__content__close",
                onClick: $options.clear
              }, {
                default: withCtx(() => [
                  createVNode(_component_uv_icon, {
                    name: "close",
                    size: "11",
                    color: "#ffffff",
                    customStyle: "line-height: 12px"
                  })
                ]),
                _: 1
              }, 8, ["onClick"]))
            : createCommentVNode("", true),
          renderSlot(_ctx.$slots, "suffix", {}, undefined, true)
        ]),
        _: 3
      }, 8, ["style"]),
      createVNode(_component_v_uni_text, {
        style: normalizeStyle([_ctx.actionStyle]),
        class: normalizeClass(["uv-search__action", [($options.showActionBtn || $data.show) && 'uv-search__action--active']]),
        onClick: withModifiers($options.custom, ["stop","prevent"])
      }, {
        default: withCtx(() => [
          createTextVNode(toDisplayString(_ctx.actionText), 1)
        ]),
        _: 1
      }, 8, ["style", "class", "onClick"])
    ]),
    _: 3
  }, 8, ["onClick", "style"]))
}
const __easycom_1 = /*#__PURE__*/_export_sfc(_sfc_main$1, [['render',_sfc_render],['__scopeId',"data-v-b3baced2"]]);

const _sfc_main = {
  __name: 'shop',
  setup(__props) {

	const main = useMainStore();
	const {
		store,
		location
	} = storeToRefs(main);
	const title = ref('店铺');
	
	// 获取导航栏高度
	const { navbarHeightCss } = useNavbarHeight();

	// 返回上一页
	const $onClickLeft = () => {
		navigateBack();
	};
	
	const list = ref([]);
	const keywork = ref('');
	const page = ref(1);
	ref(10);
	const orderType = ref('');
	onLoad((options) => {
		// 从 url 上获取 参数 orderType
		orderType.value = options.orderType;
		console.log('order_type ==>', options.orderType);
		getShop('', options.orderType);
	});


	const getShop = async (keywork = '', order_type) => {
		let data = undefined;

		const params = {
			lat: location.value.latitude ? location.value.latitude : 0,
			lng: location.value.longitude ? location.value.longitude : 0,
			kw: keywork,
			shop_id: 0,
			order_type: order_type
		};

		if (order_type === 'counter_ordering') {
			data = await shopGetListWithShopKeeper(params);
		} else {
			data = await shopGetList(params);
		}
		
		if (data) {
			//console.log(data);
			if (page.value == 1) {
				list.value = data;
			} else {
				for (let i in data) {
					list.value.push(data[i]);
				}
			}
		}
	};
	//打开定位
	const openLocation$1 = (shop) => {
		//console.log(shop);
		openLocation({
			latitude: parseFloat(shop.lat),
			longitude: parseFloat(shop.lng),
			name: shop.name,
			address: shop.addressMap + shop.address,
			fail: (res) => {
				console.log(res);
			}
		});
	};
	// 打电话
	const call = (mobile) => {
		makePhoneCall({
			phoneNumber: mobile
		});
	};
	// 搜索按钮
	const search = (keywork) => {
		page.value = 1;
		getShop(keywork);
	};
	// 选中店铺
	const choice = (shop) => {
		main.SET_STORE(shop);
		$emit('refreshMenu');
		// 返回上一页
		navigateBack({
			delta: 1,
			success(res) {
				console.log(res);
				let page = getCurrentPages$1().pop();
				if (page === undefined) {
					return;
				}
				page.setData({
					store: shop
				});
			},
			fail(res) {
				console.log(res);
			}
		});
		// uni.switchTab({
		// 	url:'/pages/menu/menu',
		// 	success(res) {
		// 	},
		// 	fail(res) {
		// 		console.log(res);
		// 	}
		// });
	};

return (_ctx, _cache) => {
  const _component_uv_navbar = resolveEasycom(resolveDynamicComponent("uv-navbar"), __easycom_0$1);
  const _component_uv_search = resolveEasycom(resolveDynamicComponent("uv-search"), __easycom_1);
  const _component_v_uni_view = index$g;
  const _component_v_uni_image = index$q;
  const _component_uv_button = resolveEasycom(resolveDynamicComponent("uv-button"), __easycom_4);

  return (openBlock(), createElementBlock(Fragment, null, [
    createVNode(_component_uv_navbar, {
      fixed: true,
      title: title.value,
      "left-arrow": "",
      onLeftClick: $onClickLeft
    }, null, 8, ["title"]),
    createVNode(_component_v_uni_view, {
      style: normalizeStyle(`padding-top: ${unref(navbarHeightCss)};`)
    }, {
      default: withCtx(() => [
        createVNode(_component_v_uni_view, null, {
          default: withCtx(() => [
            createVNode(_component_uv_search, {
              margin: "30rpx",
              modelValue: keywork.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((keywork).value = $event)),
              onCustom: _cache[1] || (_cache[1] = $event => (search(keywork.value)))
            }, null, 8, ["modelValue"])
          ]),
          _: 1
        }),
        (openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (item, index) => {
          return (openBlock(), createBlock(_component_v_uni_view, { key: index }, {
            default: withCtx(() => [
              createVNode(_component_v_uni_view, {
                class: normalizeClass(["shop-card", { 'selected': item.id == unref(store).id }]),
                onClick: $event => (choice(item))
              }, {
                default: withCtx(() => [
                  createVNode(_component_v_uni_view, { class: "card-header" }, {
                    default: withCtx(() => [
                      (item.image)
                        ? (openBlock(), createBlock(_component_v_uni_image, {
                            key: 0,
                            src: item.image,
                            class: "shop-thumbnail",
                            mode: "aspectFill"
                          }, null, 8, ["src"]))
                        : createCommentVNode("", true),
                      createVNode(_component_v_uni_view, { class: "shop-info" }, {
                        default: withCtx(() => [
                          createVNode(_component_v_uni_view, { class: "shop-name" }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(item.name), 1)
                            ]),
                            _: 2
                          }, 1024),
                          createVNode(_component_v_uni_view, { class: "shop-status" }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(item.status_text), 1)
                            ]),
                            _: 2
                          }, 1024)
                        ]),
                        _: 2
                      }, 1024)
                    ]),
                    _: 2
                  }, 1024),
                  createVNode(_component_v_uni_view, { class: "body" }, {
                    default: withCtx(() => [
                      createVNode(_component_v_uni_view, { class: "body-left" }, {
                        default: withCtx(() => [
                          createVNode(_component_v_uni_view, null, {
                            default: withCtx(() => [
                              createTextVNode("距离您 " + toDisplayString(unref(kmUnit)(item.dis)), 1)
                            ]),
                            _: 2
                          }, 1024),
                          (item.distance > 0)
                            ? (openBlock(), createBlock(_component_v_uni_view, { key: 0 }, {
                                default: withCtx(() => [
                                  createTextVNode("配送距离：" + toDisplayString(item.distance + 'km ') + " & 配送费：" + toDisplayString(item.delivery_price), 1)
                                ]),
                                _: 2
                              }, 1024))
                            : (openBlock(), createBlock(_component_v_uni_view, { key: 1 }, {
                                default: withCtx(() => [
                                  createTextVNode("外卖不配送")
                                ]),
                                _: 1
                              })),
                          createVNode(_component_v_uni_view, null, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(item.addressMap + ' ' + item.address), 1)
                            ]),
                            _: 2
                          }, 1024),
                          createVNode(_component_v_uni_view, null, {
                            default: withCtx(() => [
                              createTextVNode("营业时间 " + toDisplayString(unref(formatDateTime)(item.startTime, 'hh:mm')) + " - " + toDisplayString(unref(formatDateTime)(item.endTime, 'hh:mm')), 1)
                            ]),
                            _: 2
                          }, 1024)
                        ]),
                        _: 2
                      }, 1024),
                      createVNode(_component_v_uni_view, { class: "body-right" }, {
                        default: withCtx(() => [
                          createVNode(_component_uv_button, {
                            onClick: $event => (openLocation$1(item))
                          }, {
                            default: withCtx(() => [
                              createTextVNode("导航")
                            ]),
                            _: 2
                          }, 1032, ["onClick"]),
                          createVNode(_component_uv_button, {
                            onClick: $event => (call(item.mobile))
                          }, {
                            default: withCtx(() => [
                              createTextVNode("致电")
                            ]),
                            _: 2
                          }, 1032, ["onClick"])
                        ]),
                        _: 2
                      }, 1024)
                    ]),
                    _: 2
                  }, 1024)
                ]),
                _: 2
              }, 1032, ["onClick", "class"])
            ]),
            _: 2
          }, 1024))
        }), 128))
      ]),
      _: 1
    }, 8, ["style"])
  ], 64))
}
}

};
const shop = /*#__PURE__*/_export_sfc(_sfc_main, [['__scopeId',"data-v-c440aff4"]]);

export { shop as default };
